// ============================================================================
// API 相关类型定义
// ============================================================================

import { UserInfo, WeiboData } from './index'

/** API 响应基础接口 */
export interface ApiResponse<T = any> {
  success: boolean
  data?: T
  message?: string
  code?: string
  timestamp: number
}

/** 分页参数 */
export interface PaginationParams {
  page: number
  pageSize: number
  sortBy?: string
  sortOrder?: 'asc' | 'desc'
}

/** 分页响应 */
export interface PaginatedResponse<T> {
  items: T[]
  total: number
  page: number
  pageSize: number
  totalPages: number
  hasNext: boolean
  hasPrev: boolean
}

/** 微博搜索参数 */
export interface WeiboSearchParams extends PaginationParams {
  keyword: string
  searchType?: 'comprehensive' | 'realtime' | 'hot'
  dateRange?: [string, string] // ISO date strings
  hasImage?: boolean
  hasVideo?: boolean
  hasLink?: boolean
  minRepostsCount?: number
  minCommentsCount?: number
  minLikesCount?: number
  region?: string
  language?: string
}

/** 用户搜索参数 */
export interface UserSearchParams extends PaginationParams {
  keyword?: string
  verified?: boolean
  hasAvatar?: boolean
  minFollowersCount?: number
  maxFollowersCount?: number
  location?: string
}

/** 微博详情API响应 */
export interface WeiboDetailResponse extends ApiResponse<WeiboData> {
  data: WeiboData & {
    comments?: WeiboComment[]
    reposts?: WeiboData[]
    relatedWeibos?: WeiboData[]
  }
}

/** 微博评论 */
export interface WeiboComment {
  id: string
  text: string
  user: UserInfo
  createdAt: Date
  likesCount: number
  replyCount: number
  parentId?: string
  replies?: WeiboComment[]
}

/** 热门话题 */
export interface TrendingTopic {
  id: string
  name: string
  description?: string
  weiboCount: number
  readCount: number
  discussCount: number
  category: string
  isHot: boolean
  rank?: number
  trend?: 'up' | 'down' | 'stable'
}

/** 用户关系 */
export interface UserRelation {
  userId: string
  targetUserId: string
  relationType: 'following' | 'follower' | 'mutual'
  createdAt: Date
}

/** 数据导出选项 */
export interface ExportOptions {
  format: 'json' | 'csv' | 'xlsx'
  fields?: string[]
  includeImages?: boolean
  includeComments?: boolean
  includeReposts?: boolean
  dateRange?: [string, string]
  maxRecords?: number
}

/** 批量操作参数 */
export interface BatchOperationParams {
  ids: string[]
  operation: 'delete' | 'export' | 'archive' | 'tag'
  options?: Record<string, any>
}

/** 批量操作结果 */
export interface BatchOperationResult {
  total: number
  success: number
  failed: number
  errors: Array<{
    id: string
    error: string
  }>
}
